<template>
<el-header>/会议查询
</el-header>
  <el-main>
    <el-card>
        <el-row class="header" :gutter=20>
            <el-col :span=7>
            <el-input placeholder="请输入Id" clearable v-model="queryForm.meetingId">
            </el-input>
            
            </el-col>
            <el-button type="primary" :icon="Search" @click="loadData">查找</el-button>

        </el-row>
        <el-table :data="tableData" style="width: 100%">
            <el-table-column :prop="item.prop" :label="item.lable" v-for="(item,index) in options" :key="index">
                <template #default="{row}" v-if="item.prop === 'participants'">
                    <el-button size="small" @click="participantsSearch(row)">查看人员</el-button>

            </template>
            </el-table-column>
            
        </el-table>
     

        
    </el-card>
  </el-main>
  <DialogTable 
    v-model="dialogTableVisible" 
    :dialogTitle="dialogTitle" 
    v-if="dialogTableVisible" 
    @initMeetingList="loadData()" 
    :dialogTableValue="dialogTableValue"
  />

</template>



<script setup>

import { ref } from 'vue'
import { $meetingSearch } from "../../api/meetingapi.js";
import {options} from './commonoption'
import { Search} from '@element-plus/icons-vue'
import DialogTable from './component/diaUserSearch.vue'
/*

*/
const queryForm = ref({
  meetingId:'',
});
const total=ref(0)
const tableData =ref([]) //这句话有问题
const tableDataS =ref([])
const dialogTableVisible = ref(false)
const dialogTitle=ref('')
let dialogTableValue=ref({})

const loadData = async () => {

    tableData.value=tableDataS.value;
    console.log(queryForm.value,"commonmeeting");
    const test1={...queryForm.value};
    console.log(test1,"commonmeeting");
    if(test1.meetingId==""){
        const res = await $meetingSearch()
        console.log(res.data,"commonmeeting");
        total.value=res.data.length
        tableData.value=res.data;
        tableDataS.value=res.data;
        console.log(tableDataS,"commonmeeting");
        console.log(tableData,"commonmeeting");
    }else{
        console.log(queryForm.value,"commonmeeting");
        tableData.value=tableData.value.filter(item=>item.meetingId==test1.meetingId)        
        }
}

loadData()

const participantsSearch=(row)=>{
  
    if(row==null){
    }else{
        dialogTitle.value=row.meetingId+'会议的相关人员'
        dialogTableVisible.value=true
        //console.log(JSON.stringify({meetingId:row.meetingId}))
        dialogTableValue=JSON.parse(JSON.stringify({meetingId:row.meetingId}))
        console.log(dialogTableValue)
        //dialogUserTableValue=JSON.parse(JSON.stringify(row.meeting_id))
        //console.log(dialogUserTableValue)
    }
}
</script>

<style lang="scss" scoped>
.header{
    padding-bottom: 16px;
    box-sizing: border-box;
}
</style>